//
//  LHSelectAlertBaseView.m
//  Loohoo
//
//  Created by 陈镇 on 2024/10/26.
//

#import "LHSelectAlertBaseView.h"




@interface LHSelectAlertBaseView()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong) QMUILabel *title;
@property(nonatomic,strong) QMUIButton *cancel;
@property(nonatomic,strong) QMUIButton *comfrim;

@property(nonatomic,strong) UITableView *tableView;
@property(nonatomic,strong) NSMutableArray<LHSelectAlertBase *> *dataSource;
@end

@implementation LHSelectAlertBaseView


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = UIColorHex(00000066);
        
        self.contentFrame = CGRectMake(0, 0, SCREEN_WIDTH, 426);
        
        
        [self.contentView addSubview:self.title];
        [self.contentView addSubview:self.cancel];
        [self.contentView addSubview:self.comfrim];
        [self.contentView addSubview:self.tableView];
        
        self.dataSource = [NSMutableArray array];
    }
    return self;
}
-(void)createData{
    
    LHSelectAlertBase *model = [[LHSelectAlertBase  alloc] init];
    model.icon = @"";
    model.title = @"支付宝";
    model.isSelect = NO;
    
    [self.dataSource  addObject:model];
}
-(QMUILabel *)title{
    if (!_title) {
        _title = [QMUILabel createTextColor:UIColorHex(#333333FF) font:SLFontMakeMedium(17) textAlignment:NSTextAlignmentCenter];
        _title.text = @"￥99999999";
    }
    return _title;
}

-(QMUIButton *)cancel{
    if (!_cancel) {
        _cancel = [QMUIButton createButtonImageName:@"ion_xiaodian_cha" selectImageName:@"ion_xiaodian_cha"];
//        _cancel.backgroundColor = UIColor.redColor;
        [_cancel addTarget:self action:@selector(disMissView) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancel;
}
-(QMUIButton *)comfrim{
    if (!_comfrim) {
        _comfrim = [QMUIButton createButtonTitle:@"立即支付" titleColor:UIColor.whiteColor font:SLFontMakeMedium(14)];
        _comfrim.layer.cornerRadius = 22;
        _comfrim.backgroundColor = CZMainColor;
        [_comfrim addTarget:self action:@selector(clickItem) forControlEvents:UIControlEventTouchUpInside];
    }
    return _comfrim;
}

-(UITableView *)tableView{
    if (_tableView) {
        _tableView = [[UITableView alloc] init];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
        cell.textLabel.text = self.dataSource[indexPath.row].title;
    }
    return cell;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    
    
    _title.frame = CGRectMake(0, 0, self.width, 72);
    _cancel.frame = CGRectMake(self.width - 48, 8, 48, 48);
    _comfrim.frame = CGRectMake(12, self.contentView.height - bottomToViewNO(0), self.contentView.width - 24, 44);
    _tableView.frame = CGRectMake(0, self.title.bottom,self.contentView.width, self.contentView.height - bottomToViewNO(0) - self.comfrim.height);
    
}

-(void)clickItem{
    
    
}


@end

